<template>

  <!-- 添加或修改盘点计划对话框 -->
  <el-dialog :title="title" v-if="open" v-model="open" width="1200px" append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="90px" :inline="true">
      <el-form-item label="查询条件:" prop="categoryName">
        <el-input v-model="queryParams.categoryName" placeholder="请输入商品名称或商品ID"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-card class="box-card" shadow="always">
      <el-table v-loading="loading" :data="dataSource" @selection-change="handleSelectionChange" :row-key="getRowKey">
        <el-table-column type="selection" width="55" align="center" :selectable="selectHandle"
          :reserve-selection="true" />
        <el-table-column label="#" type="index"> </el-table-column>
        <el-table-column label="商品主图" align="center" prop="warehouseName" />
        <el-table-column label="商品名称" align="center" prop="warehouseName" width="150" />
        <el-table-column label="商品分类" align="center" prop="warehouseName" width="150" />
        <el-table-column label="商品品牌" align="center" prop="warehouseName" />
        <el-table-column label="代发" align="center" prop="warehouseName" />
        <el-table-column label="是否上架" align="center" prop="warehouseName" />
        <el-table-column label="集采成本价" align="center" prop="warehouseName" />
        <el-table-column label="批发价" align="center" prop="warehouseName" />
      </el-table>
    </el-card>

    <template #footer>
      <div class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="submitForm">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script>
export default {
  name: "selectMaterialForm",
  data() {
    return {
      open: false,
      title: "选择商品",
      form: {
        categoryId: "",
        categoryName: ""
      },
      rules: {
        categoryId: [
          { required: true, message: "Please select a category", trigger: "change" }
        ],
        categoryName: [
          { required: true, message: "Please enter a category name", trigger: "blur" }
        ]
      },
      queryParams: {
        categoryId: "",
        categoryName: ""
      },
      active: 1,
      baseInput: 200,
      data: [],
      dateRange: [],
      dataSource: [],
      loading: false,
    }
  },
  methods: {
    show() {
      this.open = true;
    },
    submitForm() {
      this.$refs.form.validate(valid => {
        if (valid) {
          // Perform form submission logic here
        } else {
          // Handle form validation errors
        }
      });
    },
    cancel() {
      this.open = false;
    },
    categoryChange(value) {
      this.form.categoryId = value;
    },
    handleSelectionChange(val) {
      this.multiple = val.length > 1;
    },
    selectHandle(row) {
      return row.orderStatus === 1;
    },
    handleQuery() {
      // Implement the logic to handle querying the table based on the search criteria
    },
    resetQuery() {
      // Implement the logic to reset the search criteria
    },
    getRowKey(row) {
      return row.id;
    },
  }
}
</script>

<style lang="scss" scoped></style>